package com.tengju.bff.interfaces.shared;

/**
 * @author: 大木
 * @date: 2021/12/13 10:31 下午
 */
public class TimeUtil {

    /**
     * 把时间转换为：时分秒格式。
     *
     * @param second 秒
     * @return {@link String}
     */
    public static String formatSecond(long second) {
        String result = "";
        String secondStr = "";
        String minStr = "";
        String hourStr = "";
        int s = (int) second % 60;
        int min = (int) second / 60;
        int hour = 0;
        if (min >= 60) {
            hour = min / 60;
            min = min % 60;
        }
        if (s < 10) {
            secondStr = "0" + s;
        } else {
            secondStr = s + "";
        }
        if (min < 10) {
            minStr = "0" + min;
        } else {
            minStr = min + "";
        }
        if (hour < 10) {
            hourStr = "0" + hour;
        } else {
            hourStr = hour + "";
        }
        if (hour != 0) {
            result = hourStr + ":" + minStr + ":" + secondStr;
        } else {
            result = minStr + ":" + secondStr;
        }
        return result;
    }

}
